<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Include/nrf_gpio.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>



<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF Enhanced Shockburst
   &#160;<span id="projectnumber">version 0.4.2</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('nrf__gpio_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Include/nrf_gpio.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef NRF_GPIO_H__</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define NRF_GPIO_H__</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;nrf51.h&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;nrf51_bitfields.h&quot;</span>
<a name="l00006"></a>00006 
<a name="l00024"></a><a class="code" href="group__nrf__gpio.html#ga494d7ac30db1cbb6366e0b9ebd5b49b4">00024</a> <span class="keyword">typedef</span> <span class="keyword">enum</span>
<a name="l00025"></a>00025 {
<a name="l00026"></a><a class="code" href="group__nrf__gpio.html#gga494d7ac30db1cbb6366e0b9ebd5b49b4a90b7ce7a76775cb7534487635755be3f">00026</a>     <a class="code" href="group__nrf__gpio.html#gga494d7ac30db1cbb6366e0b9ebd5b49b4a90b7ce7a76775cb7534487635755be3f" title="Output.">NRF_GPIO_PORT_DIR_OUTPUT</a>,       
<a name="l00027"></a><a class="code" href="group__nrf__gpio.html#gga494d7ac30db1cbb6366e0b9ebd5b49b4a6ec5811669635e30b9dc014e1f494936">00027</a>     <a class="code" href="group__nrf__gpio.html#gga494d7ac30db1cbb6366e0b9ebd5b49b4a6ec5811669635e30b9dc014e1f494936" title="Input.">NRF_GPIO_PORT_DIR_INPUT</a>         
<a name="l00028"></a>00028 } <a class="code" href="group__nrf__gpio.html#ga494d7ac30db1cbb6366e0b9ebd5b49b4" title="Enumerator used for setting the direction of a GPIO port.">nrf_gpio_port_dir_t</a>;
<a name="l00029"></a>00029 
<a name="l00034"></a><a class="code" href="group__nrf__gpio.html#ga4089fa9e3311c34d254d4d00029911bc">00034</a> <span class="keyword">typedef</span> <span class="keyword">enum</span>
<a name="l00035"></a>00035 {
<a name="l00036"></a><a class="code" href="group__nrf__gpio.html#gga4089fa9e3311c34d254d4d00029911bcadcb15e081def4002ed564fd8abbaa29d">00036</a>     <a class="code" href="group__nrf__gpio.html#gga4089fa9e3311c34d254d4d00029911bcadcb15e081def4002ed564fd8abbaa29d" title="Input.">NRF_GPIO_PIN_DIR_INPUT</a>,   
<a name="l00037"></a><a class="code" href="group__nrf__gpio.html#gga4089fa9e3311c34d254d4d00029911bca51b31d6f52c664433688ecc535e49f54">00037</a>     <a class="code" href="group__nrf__gpio.html#gga4089fa9e3311c34d254d4d00029911bca51b31d6f52c664433688ecc535e49f54" title="Output.">NRF_GPIO_PIN_DIR_OUTPUT</a>   
<a name="l00038"></a>00038 } <a class="code" href="group__nrf__gpio.html#ga4089fa9e3311c34d254d4d00029911bc">nrf_gpio_pin_dir_t</a>;
<a name="l00039"></a>00039 
<a name="l00044"></a><a class="code" href="group__nrf__gpio.html#gaa1a5c145e334817f2d960317d64fcb3d">00044</a> <span class="keyword">typedef</span> <span class="keyword">enum</span>
<a name="l00045"></a>00045 {
<a name="l00046"></a><a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3dada4c86d9760e81857ec0482c1cc78190">00046</a>     <a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3dada4c86d9760e81857ec0482c1cc78190" title="Port 0 (GPIO pin 0-7)">NRF_GPIO_PORT_SELECT_PORT0</a> = 0,           
<a name="l00047"></a><a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3da9209d7820d65eb58c7804e676581bf40">00047</a>     <a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3da9209d7820d65eb58c7804e676581bf40" title="Port 1 (GPIO pin 8-15)">NRF_GPIO_PORT_SELECT_PORT1</a>,               
<a name="l00048"></a><a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3daf83f3be082e45a73102618f149448fc8">00048</a>     <a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3daf83f3be082e45a73102618f149448fc8" title="Port 2 (GPIO pin 16-23)">NRF_GPIO_PORT_SELECT_PORT2</a>,               
<a name="l00049"></a><a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3da9075a015252fd02d27ba7ca897aa564d">00049</a>     <a class="code" href="group__nrf__gpio.html#ggaa1a5c145e334817f2d960317d64fcb3da9075a015252fd02d27ba7ca897aa564d" title="Port 3 (GPIO pin 24-31)">NRF_GPIO_PORT_SELECT_PORT3</a>,               
<a name="l00050"></a>00050 } <a class="code" href="group__nrf__gpio.html#gaa1a5c145e334817f2d960317d64fcb3d" title="Enumerator used for selecting between port 0 - 3.">nrf_gpio_port_select_t</a>;
<a name="l00051"></a>00051 
<a name="l00056"></a><a class="code" href="group__nrf__gpio.html#ga07e0c8c0b30499cf0a7b79dbe62d3fcc">00056</a> <span class="keyword">typedef</span> <span class="keyword">enum</span>
<a name="l00057"></a>00057 {
<a name="l00058"></a><a class="code" href="group__nrf__gpio.html#gga07e0c8c0b30499cf0a7b79dbe62d3fcca13ffcb94eb78be866c66b5f5b516af65">00058</a>     <a class="code" href="group__nrf__gpio.html#gga07e0c8c0b30499cf0a7b79dbe62d3fcca13ffcb94eb78be866c66b5f5b516af65" title="Pin pullup resistor disabled.">NRF_GPIO_PIN_NOPULL</a>   = GPIO_PIN_CNF_PULL_Disabled,                 
<a name="l00059"></a><a class="code" href="group__nrf__gpio.html#gga07e0c8c0b30499cf0a7b79dbe62d3fcca314d4b349d7e59ea3373a1ced4f32e4d">00059</a>     <a class="code" href="group__nrf__gpio.html#gga07e0c8c0b30499cf0a7b79dbe62d3fcca314d4b349d7e59ea3373a1ced4f32e4d" title="Pin pulldown resistor enabled.">NRF_GPIO_PIN_PULLDOWN</a> = GPIO_PIN_CNF_PULL_Pulldown,                 
<a name="l00060"></a><a class="code" href="group__nrf__gpio.html#gga07e0c8c0b30499cf0a7b79dbe62d3fccad60f768c699495d9976a45fa7a9f51c6">00060</a>     <a class="code" href="group__nrf__gpio.html#gga07e0c8c0b30499cf0a7b79dbe62d3fccad60f768c699495d9976a45fa7a9f51c6" title="Pin pullup resistor enabled.">NRF_GPIO_PIN_PULLUP</a>   = GPIO_PIN_CNF_PULL_Pullup,                   
<a name="l00061"></a>00061 } <a class="code" href="group__nrf__gpio.html#ga07e0c8c0b30499cf0a7b79dbe62d3fcc" title="Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration.">nrf_gpio_pin_pull_t</a>;
<a name="l00062"></a>00062 
<a name="l00074"></a><a class="code" href="group__nrf__gpio.html#ga08c820bf0360c7406b64ddaf3bfc7222">00074</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga08c820bf0360c7406b64ddaf3bfc7222" title="Configure GPIO pin range as outputs with normal drive strength. This function can be used to configur...">nrf_gpio_range_cfg_output</a>(uint32_t pin_range_start, uint32_t pin_range_end)
<a name="l00075"></a>00075 {
<a name="l00076"></a>00076     <span class="comment">/*lint -e{845} // A zero has been given as right argument to operator &#39;|&#39;&quot; */</span>
<a name="l00077"></a>00077     <span class="keywordflow">for</span> (; pin_range_start &lt;= pin_range_end; pin_range_start++)
<a name="l00078"></a>00078     {
<a name="l00079"></a>00079         NRF_GPIO-&gt;PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled &lt;&lt; GPIO_PIN_CNF_SENSE_Pos)
<a name="l00080"></a>00080                                         | (GPIO_PIN_CNF_DRIVE_S0S1 &lt;&lt; GPIO_PIN_CNF_DRIVE_Pos)
<a name="l00081"></a>00081                                         | (GPIO_PIN_CNF_PULL_Disabled &lt;&lt; GPIO_PIN_CNF_PULL_Pos)
<a name="l00082"></a>00082                                         | (GPIO_PIN_CNF_INPUT_Connect &lt;&lt; GPIO_PIN_CNF_INPUT_Pos)
<a name="l00083"></a>00083                                         | (GPIO_PIN_CNF_DIR_Output &lt;&lt; GPIO_PIN_CNF_DIR_Pos);
<a name="l00084"></a>00084     }
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 
<a name="l00100"></a><a class="code" href="group__nrf__gpio.html#ga6d5c4a1b82ed45f7972aea6572e085f5">00100</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga6d5c4a1b82ed45f7972aea6572e085f5" title="Configure GPIO pin range as inputs with given initial value set, hiding inner details. This function can be used to configure pin range as simple input.">nrf_gpio_range_cfg_input</a>(uint32_t pin_range_start, uint32_t pin_range_end, <a class="code" href="group__nrf__gpio.html#ga07e0c8c0b30499cf0a7b79dbe62d3fcc" title="Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration.">nrf_gpio_pin_pull_t</a> pull_config)
<a name="l00101"></a>00101 {
<a name="l00102"></a>00102     <span class="comment">/*lint -e{845} // A zero has been given as right argument to operator &#39;|&#39;&quot; */</span>
<a name="l00103"></a>00103     <span class="keywordflow">for</span> (; pin_range_start &lt;= pin_range_end; pin_range_start++)
<a name="l00104"></a>00104     {
<a name="l00105"></a>00105         NRF_GPIO-&gt;PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled &lt;&lt; GPIO_PIN_CNF_SENSE_Pos)
<a name="l00106"></a>00106                                         | (GPIO_PIN_CNF_DRIVE_S0S1 &lt;&lt; GPIO_PIN_CNF_DRIVE_Pos)
<a name="l00107"></a>00107                                         | (pull_config &lt;&lt; GPIO_PIN_CNF_PULL_Pos)
<a name="l00108"></a>00108                                         | (GPIO_PIN_CNF_INPUT_Connect &lt;&lt; GPIO_PIN_CNF_INPUT_Pos)
<a name="l00109"></a>00109                                         | (GPIO_PIN_CNF_DIR_Input &lt;&lt; GPIO_PIN_CNF_DIR_Pos);
<a name="l00110"></a>00110     }
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112 
<a name="l00121"></a><a class="code" href="group__nrf__gpio.html#ga0271806dc37bffea02d199474d526a35">00121</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga0271806dc37bffea02d199474d526a35" title="Configure given GPIO pin number as output with given initial value set, hiding inner details...">nrf_gpio_cfg_output</a>(uint32_t pin_number)
<a name="l00122"></a>00122 {
<a name="l00123"></a>00123     <span class="comment">/*lint -e{845} // A zero has been given as right argument to operator &#39;|&#39;&quot; */</span>
<a name="l00124"></a>00124     NRF_GPIO-&gt;PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled &lt;&lt; GPIO_PIN_CNF_SENSE_Pos)
<a name="l00125"></a>00125                                             | (GPIO_PIN_CNF_DRIVE_S0S1 &lt;&lt; GPIO_PIN_CNF_DRIVE_Pos)
<a name="l00126"></a>00126                                             | (GPIO_PIN_CNF_PULL_Disabled &lt;&lt; GPIO_PIN_CNF_PULL_Pos)
<a name="l00127"></a>00127                                             | (GPIO_PIN_CNF_INPUT_Connect &lt;&lt; GPIO_PIN_CNF_INPUT_Pos)
<a name="l00128"></a>00128                                             | (GPIO_PIN_CNF_DIR_Output &lt;&lt; GPIO_PIN_CNF_DIR_Pos);
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 
<a name="l00141"></a><a class="code" href="group__nrf__gpio.html#ga4e63d442ebd572126be3e030b3df4dc6">00141</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga4e63d442ebd572126be3e030b3df4dc6" title="Configure given GPIO pin number as input with given initial value set, hiding inner details...">nrf_gpio_cfg_input</a>(uint32_t pin_number, <a class="code" href="group__nrf__gpio.html#ga07e0c8c0b30499cf0a7b79dbe62d3fcc" title="Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration.">nrf_gpio_pin_pull_t</a> pull_config)
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143     <span class="comment">/*lint -e{845} // A zero has been given as right argument to operator &#39;|&#39;&quot; */</span>
<a name="l00144"></a>00144     NRF_GPIO-&gt;PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled &lt;&lt; GPIO_PIN_CNF_SENSE_Pos)
<a name="l00145"></a>00145                                         | (GPIO_PIN_CNF_DRIVE_S0S1 &lt;&lt; GPIO_PIN_CNF_DRIVE_Pos)
<a name="l00146"></a>00146                                         | (pull_config &lt;&lt; GPIO_PIN_CNF_PULL_Pos)
<a name="l00147"></a>00147                                         | (GPIO_PIN_CNF_INPUT_Connect &lt;&lt; GPIO_PIN_CNF_INPUT_Pos)
<a name="l00148"></a>00148                                         | (GPIO_PIN_CNF_DIR_Input &lt;&lt; GPIO_PIN_CNF_DIR_Pos);
<a name="l00149"></a>00149 }
<a name="l00150"></a>00150 
<a name="l00159"></a><a class="code" href="group__nrf__gpio.html#gaaa7d06cd383f816f71e277b97ca5f3d9">00159</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#gaaa7d06cd383f816f71e277b97ca5f3d9" title="Set the direction for a GPIO pin.">nrf_gpio_pin_dir_set</a>(uint32_t pin_number, <a class="code" href="group__nrf__gpio.html#ga4089fa9e3311c34d254d4d00029911bc">nrf_gpio_pin_dir_t</a> direction)
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161     <span class="keywordflow">if</span>(direction == <a class="code" href="group__nrf__gpio.html#gga4089fa9e3311c34d254d4d00029911bcadcb15e081def4002ed564fd8abbaa29d" title="Input.">NRF_GPIO_PIN_DIR_INPUT</a>)
<a name="l00162"></a>00162     {
<a name="l00163"></a>00163         NRF_GPIO-&gt;PIN_CNF[pin_number] =
<a name="l00164"></a>00164           (GPIO_PIN_CNF_SENSE_Disabled &lt;&lt; GPIO_PIN_CNF_SENSE_Pos)
<a name="l00165"></a>00165         | (GPIO_PIN_CNF_DRIVE_S0S1 &lt;&lt; GPIO_PIN_CNF_DRIVE_Pos)
<a name="l00166"></a>00166         | (GPIO_PIN_CNF_PULL_Disabled &lt;&lt; GPIO_PIN_CNF_PULL_Pos)
<a name="l00167"></a>00167         | (GPIO_PIN_CNF_INPUT_Connect &lt;&lt; GPIO_PIN_CNF_INPUT_Pos)
<a name="l00168"></a>00168         | (GPIO_PIN_CNF_DIR_Input &lt;&lt; GPIO_PIN_CNF_DIR_Pos);
<a name="l00169"></a>00169     }
<a name="l00170"></a>00170     <span class="keywordflow">else</span>
<a name="l00171"></a>00171     {
<a name="l00172"></a>00172         NRF_GPIO -&gt; DIRSET = (1UL &lt;&lt; pin_number);
<a name="l00173"></a>00173     }
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 
<a name="l00185"></a><a class="code" href="group__nrf__gpio.html#gacaf7e8e242a47f7b635bbeca5c5934a3">00185</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#gacaf7e8e242a47f7b635bbeca5c5934a3" title="Set GPIO pin.">nrf_gpio_pin_set</a>(uint32_t pin_number)
<a name="l00186"></a>00186 {
<a name="l00187"></a>00187     NRF_GPIO-&gt;OUTSET = (1UL &lt;&lt; pin_number);
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 
<a name="l00199"></a><a class="code" href="group__nrf__gpio.html#gaf3de3729249d55592c86ecfa97fb9347">00199</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#gaf3de3729249d55592c86ecfa97fb9347" title="Clear GPIO pin.">nrf_gpio_pin_clear</a>(uint32_t pin_number)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201     NRF_GPIO-&gt;OUTCLR = (1UL &lt;&lt; pin_number);
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 
<a name="l00213"></a><a class="code" href="group__nrf__gpio.html#ga5c8310a3b7a81cc4a267844c81769a40">00213</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga5c8310a3b7a81cc4a267844c81769a40" title="Toggle GPIO pin.">nrf_gpio_pin_toggle</a>(uint32_t pin_number)
<a name="l00214"></a>00214 {
<a name="l00215"></a>00215     NRF_GPIO-&gt;OUT ^= (1UL &lt;&lt; pin_number);
<a name="l00216"></a>00216 }
<a name="l00217"></a>00217 
<a name="l00231"></a><a class="code" href="group__nrf__gpio.html#ga7fefa8a71e25eeb57b5b4230b0dd0484">00231</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga7fefa8a71e25eeb57b5b4230b0dd0484" title="Write value to GPIO pin.">nrf_gpio_pin_write</a>(uint32_t pin_number, uint32_t value)
<a name="l00232"></a>00232 {
<a name="l00233"></a>00233     <span class="keywordflow">if</span> (value == 0)
<a name="l00234"></a>00234     {
<a name="l00235"></a>00235         <a class="code" href="group__nrf__gpio.html#gaf3de3729249d55592c86ecfa97fb9347" title="Clear GPIO pin.">nrf_gpio_pin_clear</a>(pin_number);
<a name="l00236"></a>00236     }
<a name="l00237"></a>00237     <span class="keywordflow">else</span>
<a name="l00238"></a>00238     {
<a name="l00239"></a>00239         <a class="code" href="group__nrf__gpio.html#gacaf7e8e242a47f7b635bbeca5c5934a3" title="Set GPIO pin.">nrf_gpio_pin_set</a>(pin_number);
<a name="l00240"></a>00240     }
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242 
<a name="l00257"></a><a class="code" href="group__nrf__gpio.html#ga0983906029818d8aa199b71b578d1c12">00257</a> <span class="keyword">static</span> __INLINE uint32_t <a class="code" href="group__nrf__gpio.html#ga0983906029818d8aa199b71b578d1c12" title="Read the input level of a GPIO pin.">nrf_gpio_pin_read</a>(uint32_t pin_number)
<a name="l00258"></a>00258 {
<a name="l00259"></a>00259     <span class="keywordflow">return</span>  ((NRF_GPIO-&gt;IN &gt;&gt; pin_number) &amp; 1UL);
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261 
<a name="l00276"></a><a class="code" href="group__nrf__gpio.html#gacf721556f8a9d59b8542347c1a398bf6">00276</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#gacf721556f8a9d59b8542347c1a398bf6" title="Generic function for writing a single byte of a 32 bit word at a given address.">nrf_gpio_word_byte_write</a>(<span class="keyword">volatile</span> uint32_t * word_address, uint8_t byte_no, uint8_t value)
<a name="l00277"></a>00277 {
<a name="l00278"></a>00278     *((uint8_t*)(word_address) + byte_no) = value;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 
<a name="l00294"></a><a class="code" href="group__nrf__gpio.html#ga2a875912b5b23a75207cc3e5a61eaf0f">00294</a> <span class="keyword">static</span> __INLINE uint8_t <a class="code" href="group__nrf__gpio.html#ga2a875912b5b23a75207cc3e5a61eaf0f" title="Generic function for reading a single byte of a 32 bit word at a given address.">nrf_gpio_word_byte_read</a>(<span class="keyword">const</span> <span class="keyword">volatile</span> uint32_t* word_address, uint8_t byte_no)
<a name="l00295"></a>00295 {
<a name="l00296"></a>00296     <span class="keywordflow">return</span> (*((uint8_t*)(word_address) + byte_no));
<a name="l00297"></a>00297 }
<a name="l00298"></a>00298 
<a name="l00306"></a><a class="code" href="group__nrf__gpio.html#gaaa72c88a2a29927a1eeff691d6a21afc">00306</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#gaaa72c88a2a29927a1eeff691d6a21afc" title="Set the direction of a port.">nrf_gpio_port_dir_set</a>(<a class="code" href="group__nrf__gpio.html#gaa1a5c145e334817f2d960317d64fcb3d" title="Enumerator used for selecting between port 0 - 3.">nrf_gpio_port_select_t</a> port, <a class="code" href="group__nrf__gpio.html#ga494d7ac30db1cbb6366e0b9ebd5b49b4" title="Enumerator used for setting the direction of a GPIO port.">nrf_gpio_port_dir_t</a> dir)
<a name="l00307"></a>00307 {
<a name="l00308"></a>00308     <span class="keywordflow">if</span> (dir == <a class="code" href="group__nrf__gpio.html#gga494d7ac30db1cbb6366e0b9ebd5b49b4a90b7ce7a76775cb7534487635755be3f" title="Output.">NRF_GPIO_PORT_DIR_OUTPUT</a>)
<a name="l00309"></a>00309     {
<a name="l00310"></a>00310         <a class="code" href="group__nrf__gpio.html#gacf721556f8a9d59b8542347c1a398bf6" title="Generic function for writing a single byte of a 32 bit word at a given address.">nrf_gpio_word_byte_write</a>(&amp;NRF_GPIO-&gt;DIRSET, port, 0xFF);
<a name="l00311"></a>00311     }
<a name="l00312"></a>00312     <span class="keywordflow">else</span>
<a name="l00313"></a>00313     {
<a name="l00314"></a>00314         <a class="code" href="group__nrf__gpio.html#ga6d5c4a1b82ed45f7972aea6572e085f5" title="Configure GPIO pin range as inputs with given initial value set, hiding inner details. This function can be used to configure pin range as simple input.">nrf_gpio_range_cfg_input</a>(port*8, (port+1)*8-1, <a class="code" href="group__nrf__gpio.html#gga07e0c8c0b30499cf0a7b79dbe62d3fcca13ffcb94eb78be866c66b5f5b516af65" title="Pin pullup resistor disabled.">NRF_GPIO_PIN_NOPULL</a>);
<a name="l00315"></a>00315     }
<a name="l00316"></a>00316 }
<a name="l00317"></a>00317 
<a name="l00325"></a><a class="code" href="group__nrf__gpio.html#ga40bee84dc81b9f8981eb2647dac9d267">00325</a> <span class="keyword">static</span> __INLINE uint8_t <a class="code" href="group__nrf__gpio.html#ga40bee84dc81b9f8981eb2647dac9d267" title="Read GPIO port.">nrf_gpio_port_read</a>(<a class="code" href="group__nrf__gpio.html#gaa1a5c145e334817f2d960317d64fcb3d" title="Enumerator used for selecting between port 0 - 3.">nrf_gpio_port_select_t</a> port)
<a name="l00326"></a>00326 {
<a name="l00327"></a>00327     <span class="keywordflow">return</span> <a class="code" href="group__nrf__gpio.html#ga2a875912b5b23a75207cc3e5a61eaf0f" title="Generic function for reading a single byte of a 32 bit word at a given address.">nrf_gpio_word_byte_read</a>(&amp;NRF_GPIO-&gt;IN, port);
<a name="l00328"></a>00328 }
<a name="l00329"></a>00329 
<a name="l00339"></a><a class="code" href="group__nrf__gpio.html#gac1d4940bc5ad4aad4f6363c7021b08ae">00339</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#gac1d4940bc5ad4aad4f6363c7021b08ae" title="Write GPIO port.">nrf_gpio_port_write</a>(<a class="code" href="group__nrf__gpio.html#gaa1a5c145e334817f2d960317d64fcb3d" title="Enumerator used for selecting between port 0 - 3.">nrf_gpio_port_select_t</a> port, uint8_t value)
<a name="l00340"></a>00340 {
<a name="l00341"></a>00341     <a class="code" href="group__nrf__gpio.html#gacf721556f8a9d59b8542347c1a398bf6" title="Generic function for writing a single byte of a 32 bit word at a given address.">nrf_gpio_word_byte_write</a>(&amp;NRF_GPIO-&gt;OUT, port, value);
<a name="l00342"></a>00342 }
<a name="l00343"></a>00343 
<a name="l00355"></a><a class="code" href="group__nrf__gpio.html#ga16a605149e0f0fd93fdb49b2dcaffc43">00355</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga16a605149e0f0fd93fdb49b2dcaffc43" title="Set individual pins on GPIO port.">nrf_gpio_port_set</a>(<a class="code" href="group__nrf__gpio.html#gaa1a5c145e334817f2d960317d64fcb3d" title="Enumerator used for selecting between port 0 - 3.">nrf_gpio_port_select_t</a> port, uint8_t set_mask)
<a name="l00356"></a>00356 {
<a name="l00357"></a>00357     <a class="code" href="group__nrf__gpio.html#gacf721556f8a9d59b8542347c1a398bf6" title="Generic function for writing a single byte of a 32 bit word at a given address.">nrf_gpio_word_byte_write</a>(&amp;NRF_GPIO-&gt;OUTSET, port, set_mask);
<a name="l00358"></a>00358 }
<a name="l00359"></a>00359 
<a name="l00371"></a><a class="code" href="group__nrf__gpio.html#ga6752ee7db03061e5a3253891651c7c5e">00371</a> <span class="keyword">static</span> __INLINE <span class="keywordtype">void</span> <a class="code" href="group__nrf__gpio.html#ga6752ee7db03061e5a3253891651c7c5e" title="Clear individual pins on GPIO port.">nrf_gpio_port_clear</a>(<a class="code" href="group__nrf__gpio.html#gaa1a5c145e334817f2d960317d64fcb3d" title="Enumerator used for selecting between port 0 - 3.">nrf_gpio_port_select_t</a> port, uint8_t clr_mask)
<a name="l00372"></a>00372 {
<a name="l00373"></a>00373     <a class="code" href="group__nrf__gpio.html#gacf721556f8a9d59b8542347c1a398bf6" title="Generic function for writing a single byte of a 32 bit word at a given address.">nrf_gpio_word_byte_write</a>(&amp;NRF_GPIO-&gt;OUTCLR, port, clr_mask);
<a name="l00374"></a>00374 }
<a name="l00375"></a>00375 
<a name="l00378"></a>00378 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>nrf_gpio.h</b>      </li>

    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
